﻿ using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.Windows.Controls;
using System.Globalization;

namespace VMuktiGrid.CustomGrid
{
    //public class CPODHeight : IValueConverter
    //{
    //    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        if (value == null)
    //        {
    //            return 0.0;
    //        }

    //        if (((Visibility)value) == Visibility.Collapsed)
    //        {
    //            return 25.0;
    //        }
    //        else if (((Visibility)value) == Visibility.Visible)
    //        {
    //            return ((ScrollViewer)parameter).Height + 25.0;
    //        }
    //        else
    //        {
    //            return 0.0;
    //        }
    //    }

    //    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        return null;
    //    }
    //}

    public class CPODHeight : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null)
            {
                return 0.0;
            }

            if (((Visibility)values[0]) == Visibility.Collapsed)
            {
                return 25.0;
            }
            else if (((Visibility)values[0]) == Visibility.Visible)
            {
                if (values[1].ToString() == "NaN")
                {
                    return 25.0;
                }
                else
                {
                    return double.Parse(values[1].ToString()) + 25.0;
                }
            }
            else
            {
                return 0.0;
            }
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            string[] splitValues = ((string)value).Split(' ');
            return splitValues;
        }
    }
}
